package javatest;

import java.lang.ref.WeakReference;

public class ReferenceTest {
    public static void main(String[] args) {
        testWeakReference();
    }

    public static void testWeakReference() {
        byte[] myByteArray = new byte[1];
        WeakReference weakReference = new WeakReference(myByteArray);
        System.out.println(weakReference.get());
        myByteArray = null;
        System.gc();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(weakReference.get());
    }
}
